home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / eedsrc24.zip / EEP24SRC.ZIP / EL.C < prev    next >
C/C++ Source or Header  |  1992-07-29  |  3KB  |  187 lines

  1. /* Set up the basic primitives for Layer control */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include "\usr\include\intr_lib.h"
  6. /* #include "\usr\include\intr_gr.h" */
  7. #include "program.h"
  8. #include "eelayer.h"
  9.  
  10.  
  11. #define MAX_LAYERS 44
  12. #define LAYER_OFF 0
  13. #define LAYER_ON  1
  14. #define LAYER_ENABLED 2
  15. #define LAYER_UNUSED  4
  16.  
  17. #define BLACK        0
  18. #define RED        4
  19. #define GREEN        2
  20. #define BLUE        1
  21. #define YELLOW        14
  22. #define CYAN        3
  23. #define MAGENTA        5
  24. #define WHITE        15
  25.  
  26.  
  27. static char *UsedLayers[] ={
  28.     "Wire",
  29.     "Bus",
  30.     "Gate",
  31.     "IEEE",
  32.     "PinFun",
  33.     "PinNum",
  34.     "PinNam",
  35.     "RefDes",
  36.     "Attr",
  37.     "Device",
  38.     "Notes",
  39.     "NetNam",
  40.     "Pin",
  41.     "END"
  42. };
  43. static int LayerInfo[] ={
  44.      WHITE,0x8200,
  45.      YELLOW,0x0100,
  46.      CYAN,0x0100,
  47.      RED,0x0100, 
  48.      BLUE,0x0100, 
  49.      YELLOW,0x0100, 
  50.      BLUE,0x0100, 
  51.      YELLOW,0x0100, 
  52.      YELLOW,0x0100, 
  53.      CYAN,0x0100, 
  54.      BLUE,0x0100, 
  55.      RED,0x0100,
  56.      WHITE,0x0100
  57. };
  58.  
  59. struct LayerStruct *Layer; 
  60.  
  61. void SeedLayers()
  62.  
  63. {
  64.     int pt;
  65.     
  66.     Layer = (LayerStruct *) MyMalloc(sizeof(LayerStruct));
  67.     
  68.     
  69.     pt=0;
  70.     Layer->CurrentWidth = 1;
  71. /* seed Up the Layer Strings and colours, set all user layers off */
  72.     while((strcmp(UsedLayers[pt],"END"))!=0){
  73.         /* set layer name up */
  74.      
  75.         strcpy(Layer->LayerNames[pt],UsedLayers[pt]);
  76.         Layer->LayerStatus[pt]=
  77.              (LayerInfo[(pt * 2) +1] & 0x0f00)/0x100;
  78.  
  79.         Layer->LayerColor[pt] = LayerInfo[(pt * 2)];
  80.  
  81.         if(LayerInfo[(pt * 2) +1] & 0x8200)
  82.             Layer->CurrentLayer=pt;
  83.      
  84.         pt++;
  85.     }
  86.      
  87.     Layer->NumberOfLayers=pt-1;
  88.     while(pt!=MAX_LAYERS){
  89.         sprintf(Layer->LayerNames[pt],"User%d",pt);
  90.  
  91.         
  92.         Layer->LayerStatus[pt] = LAYER_UNUSED;
  93.                             /* layers clear */
  94.                             /* and Off */
  95.         Layer->LayerColor[pt] = INTR_COLOR_BLACK;
  96.         /* Colours Black */ 
  97.         pt++;
  98.     }
  99.     
  100.  
  101.      
  102. }
  103. int ReturnCurrentWidth()
  104. {
  105.     return(LayerPointer -> CurrentWidth);
  106. }
  107. void SetCurrentWidth(int Width)
  108. {
  109.     LayerPointer -> CurrentWidth = Width;
  110. }
  111. int ReturnCurrentLayer()
  112. {
  113.     return(LayerPointer -> CurrentLayer);
  114. }
  115. void SetCurrentLayer(int Layer)
  116. {
  117.     LayerPointer->CurrentLayer = Layer;
  118. }
  119. char *ReturnLayerName(Layer)
  120. int Layer;
  121. {
  122.     return(LayerPointer->LayerNames[Layer]);
  123. }
  124. void SetLayerName(Layer,Name)
  125. int Layer;
  126. char *Name;
  127. {
  128.     strcpy(LayerPointer->LayerNames[Layer],Name);
  129. }
  130. int ReturnLayerMode(Layer)
  131. int Layer;
  132. {
  133.     return(LayerPointer->LayerStatus[Layer]);
  134. }
  135. void SetLayerMode(Layer,Mode)
  136. int Layer,Mode;
  137. {
  138.     LayerPointer->LayerStatus[Layer]=Mode;
  139. }
  140.  
  141. int ReturnLayerColor(Layer)
  142. int Layer;
  143. {
  144.     return(LayerPointer->LayerColor[Layer]);
  145.      
  146. }
  147. void SetLayerColor(Layer,Color)
  148. int Layer,Color;
  149. {
  150.     LayerPointer->LayerColor[Layer]=Color;
  151. }
  152. int ReturnLayerNumber()
  153. {
  154.     return(LayerPointer->NumberOfLayers);
  155. }
  156. void SetLayerNumber(Number)
  157. int Number;
  158. {
  159.     LayerPointer->NumberOfLayers=Number;
  160. }
  161. void LoadLayers(f)
  162. FILE *f;    /* Load the Layer Structuer from a file */
  163. {
  164.     int cnt,Number;
  165.     char Line[LINE_LEN];
  166.     int Mode,Color,Layer;
  167.     char Name[0x10];
  168.  
  169.     fgets(Line,LINE_LEN-1,f);    /* read line */
  170.     sscanf(Line,"%s %d %d",Name,&Number,&LayerPointer->CurrentLayer);
  171.     if((strcmp(Name,"EELAYER"))!=0){
  172.         /* Error! */
  173.     } else
  174.         SetLayerNumber(Number);
  175.     cnt=0;
  176.     while(cnt!=Number+1){
  177.         fgets(Line,LINE_LEN-1,f);    /* read line */
  178.         sscanf(Line,"%s %d %d %d",Name,&Color,&Mode,&Layer);
  179.         SetLayerName(Layer,Name);
  180.         SetLayerColor(Layer,Color);
  181.         SetLayerMode(Layer,Mode);
  182.         cnt++;
  183.     }
  184.     fgets(Line,LINE_LEN-1,f);    /* read trailing Line */
  185.  
  186. }
  187.